/**
  缓冲清理中间件
 */

export default function ({ route,store, redirect }) {
  if(route.matched[0]){
    let path = route.matched[0].path;
    //清理转账流程session
    if(path !== '/accept'){
      store.dispatch('accept/clear');
    }

    //清理支付流程session
    if(path !== '/pay'){
      store.dispatch('pay/clear');
    }

    //清理代付流程session
    if(path !== '/elsepay'){
      store.dispatch('elsepay/clear');
    }

    //清理充值流程session
    if (!/^\/wealth\/recharge/i.test(route.path)) {
      store.dispatch('recharge/clear');
    }

    //清理提现流程session
    if (!/^\/wealth\/draw/i.test(route.path)) {
      store.dispatch('draw/clear');
    }
  }
}
